<template>
  <div style="width:100%;height:100%;overflow:hidden">
    <weui-cell :list="cell_0_list" style="height:100%;overflow-y:auto">
    </weui-cell>
  </div>
</template>

<script>
  import WeuiCell from '../vue2componentSet/src/components/WeuiCell'
  import global from '../lib/global'
  import axios from 'axios'

  export default {
    components: {
      WeuiCell
    },
    data() {
      return {
        cell_0_list: []
      }
    },
    mounted() {
      this.$store.commit('set_title', '订单统计')

      if (!this.$store.state.admin) {
        this.$router.goback()
        return
      }

      axios.post(global.server + 'getBillData.do', {}).then(result => {
        const obj = result.data
        if (obj.result == 0) {
          this.$store.commit('admin_login', null)
          this.$router.goback()
          return
        }
        var cnt = 0, sum = 0
        obj.data.forEach(item => {
          cnt += item.count
          sum += parseFloat(item.sum)
        })
        this.cell_0_list.push({
          value: '全部',
          desc: '[' + cnt + ']￥' + sum,
          link: '#/customerBill?customer_phone=*'
        })
        obj.data.forEach(item => {
          this.cell_0_list.push({
            value: item.customer_phone,
            desc: '[' + item.count + ']￥' + item.sum,
            link: '#/customerBill?customer_phone=' + item.customer_phone
          })
        })
      }, result => {
      })
    }
  }
</script>
